package cn.yrec.rain.analysis.domain;


import cn.yrec.rain.analysis.enums.ResponseCode;
import org.springframework.http.HttpStatus;

/**
 * 
* @ClassName: ResponseData 
* @Description: 响应信息
* @author zhupt
* @date 2019年1月2日 下午2:51:32 
*
 */
public class ResponseData {
	
	private int code = 200;
	
	private String msg = "";
	
	private Object data;

	public static ResponseData ok(Object data) {
		return new ResponseData(data);
	}

	public static ResponseData ok(String msg, Object data) {
		return new ResponseData(msg, data);
	}
	
	public static ResponseData fail() {
		return new ResponseData(null);
	}

	public static ResponseData fail(HttpStatus status, String msg) {
		return new ResponseData(status.value(), msg);
	}

	public static ResponseData fail(String message) {
		return new ResponseData(message);
	}

	public static ResponseData fail(String message, int code) {
		return new ResponseData(message, code);
	}

	public static ResponseData fail(int code, String message) {
		return new ResponseData(message, code);
	}

	public static ResponseData fail(String message, Object data) {
		return new ResponseData(message, data);
	}

	public static ResponseData failByParam(String message) {
		return new ResponseData(message, ResponseCode.PARAM_ERROR_CODE.getCode());
	}

	public static ResponseData failByServer(String message) {
		return new ResponseData(message, ResponseCode.SERVER_ERROR_CODE.getCode());
	}
	
	public ResponseData(Object data) {
		super();
		this.data = data;
	}

	public ResponseData(String msg, Object data) {
		super();
		this.msg = msg;
		this.data = data;
	}
	
	public ResponseData(String msg) {
		super();
		this.msg = msg;
	}

	public ResponseData(String msg, int code) {
		super();
		this.msg = msg;
		this.code = code;
	}

	public ResponseData(int code, String msg) {
		super();
		this.msg = msg;
		this.code = code;
	}

	public ResponseData() {
		super();
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

}
